<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>模型管理 - Nova Flow</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="../css/styles.css">
</head>
<body class="bg-gray-50 dark:bg-gray-900 text-gray-800 dark:text-gray-200 p-6">
    <div class="flex justify-between items-center mb-6">
        <h1 class="text-2xl font-bold">模型管理</h1>
        <button id="addModelBtn" class="btn btn-primary">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 inline-block mr-1" viewBox="0 0 20 20" fill="currentColor">
                <path fill-rule="evenodd" d="M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z" clip-rule="evenodd" />
            </svg>
            添加模型
        </button>
    </div>
    
    <!-- 模型筛选 -->
    <div class="mb-6 flex flex-wrap gap-3">
        <span class="text-sm font-medium mr-2">筛选:</span>
        <button class="px-3 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 rounded-full text-sm font-medium active">全部</button>
        <button class="px-3 py-1 bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-full text-sm font-medium">OpenAI</button>
        <button class="px-3 py-1 bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-full text-sm font-medium">本地模型</button>
        <button class="px-3 py-1 bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-full text-sm font-medium">自定义</button>
    </div>
    
    <!-- 模型列表 -->
    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-8">
        <!-- GPT-4 模型 -->
        <div class="card">
            <div class="flex justify-between items-start mb-4">
                <div>
                    <h2 class="text-lg font-semibold">GPT-4</h2>
                    <span class="inline-block px-2 py-1 bg-green-100 dark:bg-green-900 text-green-700 dark:text-green-300 rounded text-xs mt-1">已连接</span>
                </div>
                <div class="flex">
                    <button class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 mr-2">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
                        </svg>
                    </button>
                    <button class="text-red-500 hover:text-red-700">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
                        </svg>
                    </button>
                </div>
            </div>
            <p class="text-sm text-gray-600 dark:text-gray-400 mb-4">OpenAI 的高级语言模型，具有优秀的推理和对话能力。</p>
            <div class="space-y-2 text-sm">
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">提供商</span>
                    <span>OpenAI</span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">类型</span>
                    <span>大语言模型</span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">权限</span>
                    <span>全部</span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">本月调用次数</span>
                    <span>857</span>
                </div>
            </div>
            <div class="mt-4 pt-4 border-t border-gray-200 dark:border-gray-700">
                <button class="btn btn-primary w-full">设置模型参数</button>
            </div>
        </div>
        
        <!-- GPT-3.5 模型 -->
        <div class="card">
            <div class="flex justify-between items-start mb-4">
                <div>
                    <h2 class="text-lg font-semibold">GPT-3.5 Turbo</h2>
                    <span class="inline-block px-2 py-1 bg-green-100 dark:bg-green-900 text-green-700 dark:text-green-300 rounded text-xs mt-1">已连接</span>
                </div>
                <div class="flex">
                    <button class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 mr-2">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
                        </svg>
                    </button>
                    <button class="text-red-500 hover:text-red-700">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
                        </svg>
                    </button>
                </div>
            </div>
            <p class="text-sm text-gray-600 dark:text-gray-400 mb-4">性能优秀且经济高效的AI模型，适合大多数通用应用场景。</p>
            <div class="space-y-2 text-sm">
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">提供商</span>
                    <span>OpenAI</span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">类型</span>
                    <span>大语言模型</span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">权限</span>
                    <span>全部</span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">本月调用次数</span>
                    <span>1,392</span>
                </div>
            </div>
            <div class="mt-4 pt-4 border-t border-gray-200 dark:border-gray-700">
                <button class="btn btn-primary w-full">设置模型参数</button>
            </div>
        </div>
        
        <!-- 本地模型 -->
        <div class="card">
            <div class="flex justify-between items-start mb-4">
                <div>
                    <h2 class="text-lg font-semibold">本地 LLaMA 2</h2>
                    <span class="inline-block px-2 py-1 bg-green-100 dark:bg-green-900 text-green-700 dark:text-green-300 rounded text-xs mt-1">已连接</span>
                </div>
                <div class="flex">
                    <button class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 mr-2">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
                        </svg>
                    </button>
                    <button class="text-red-500 hover:text-red-700">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
                        </svg>
                    </button>
                </div>
            </div>
            <p class="text-sm text-gray-600 dark:text-gray-400 mb-4">本地部署的LLaMA模型，适合对数据安全和隐私有较高要求的场景。</p>
            <div class="space-y-2 text-sm">
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">提供商</span>
                    <span>本地部署</span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">类型</span>
                    <span>大语言模型</span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">权限</span>
                    <span>高级用户</span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-500 dark:text-gray-400">本月调用次数</span>
                    <span>421</span>
                </div>
            </div>
            <div class="mt-4 pt-4 border-t border-gray-200 dark:border-gray-700">
                <button class="btn btn-primary w-full">设置模型参数</button>
            </div>
        </div>
    </div>
    
    <!-- 添加模型表单模态框 -->
    <div id="addModelModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
        <div class="bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md mx-4">
            <div class="flex justify-between items-center mb-4">
                <h2 class="text-xl font-bold">添加新模型</h2>
                <button id="closeModalBtn" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                    </svg>
                </button>
            </div>
            <form id="addModelForm">
                <div class="mb-4">
                    <label for="modelName" class="block text-sm font-medium mb-1">模型名称</label>
                    <input type="text" id="modelName" class="form-input" placeholder="例如: GPT-4" required>
                </div>
                <div class="mb-4">
                    <label for="modelProvider" class="block text-sm font-medium mb-1">提供商</label>
                    <select id="modelProvider" class="form-input">
                        <option value="openai">OpenAI</option>
                        <option value="local">本地模型</option>
                        <option value="custom">自定义</option>
                    </select>
                </div>
                <div class="mb-4">
                    <label for="modelType" class="block text-sm font-medium mb-1">模型类型</label>
                    <select id="modelType" class="form-input">
                        <option value="llm">大语言模型 (LLM)</option>
                        <option value="embedding">嵌入模型</option>
                        <option value="vision">视觉模型</option>
                        <option value="speech">语音模型</option>
                    </select>
                </div>
                <div class="mb-4">
                    <label for="apiKey" class="block text-sm font-medium mb-1">API 密钥</label>
                    <input type="password" id="apiKey" class="form-input" placeholder="输入您的API密钥">
                </div>
                <div class="mb-4">
                    <label for="baseUrl" class="block text-sm font-medium mb-1">API 端点 (可选)</label>
                    <input type="text" id="baseUrl" class="form-input" placeholder="例如: https://api.openai.com/v1">
                </div>
                <div class="mb-4">
                    <label for="modelPermission" class="block text-sm font-medium mb-1">访问权限</label>
                    <select id="modelPermission" class="form-input">
                        <option value="all">所有用户</option>
                        <option value="admin">仅管理员</option>
                        <option value="advanced">高级用户</option>
                    </select>
                </div>
                <div class="flex justify-end space-x-3">
                    <button type="button" id="cancelAddBtn" class="px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700">取消</button>
                    <button type="submit" class="btn btn-primary">添加模型</button>
                </div>
            </form>
        </div>
    </div>
    
    <script>
        // 模态框控制
        document.getElementById('addModelBtn').addEventListener('click', function() {
            document.getElementById('addModelModal').classList.remove('hidden');
        });
        
        document.getElementById('closeModalBtn').addEventListener('click', function() {
            document.getElementById('addModelModal').classList.add('hidden');
        });
        
        document.getElementById('cancelAddBtn').addEventListener('click', function() {
            document.getElementById('addModelModal').classList.add('hidden');
        });
        
        // 表单提交
        document.getElementById('addModelForm').addEventListener('submit', function(e) {
            e.preventDefault();
            // 这里添加表单处理逻辑
            alert('模型添加功能将在后端集成后实现');
            document.getElementById('addModelModal').classList.add('hidden');
        });
        
        // 处理主页面发送的主题变更消息
        window.addEventListener('message', function(event) {
            if (event.data.type === 'themeChange') {
                if (event.data.darkMode) {
                    document.documentElement.classList.add('dark');
                } else {
                    document.documentElement.classList.remove('dark');
                }
            }
        });
        
        // 初始化检查暗色模式
        if (window.parent && window.parent.document.documentElement.classList.contains('dark')) {
            document.documentElement.classList.add('dark');
        }
    </script>
</body>
</html> 